package io.cici.worker.common;

import io.cici.common.model.App;
import io.cici.remote.framework.transporter.Transporter;
import io.cici.worker.background.discovery.ServerDiscoveryService;
import io.cici.worker.core.executor.ExecutorManager;
import io.cici.worker.persistence.TaskPersistenceService;
import io.cici.worker.processor.ProcessorLoader;
import lombok.Data;

import java.util.Optional;

/**
 * store worker's runtime
 *
 * @author tjq
 * @since 2021/3/7
 */
@Data
public class WorkerInfo {

    /**
     * App 基础信息
     */
    private App app;
    /**
     * 当前执行器地址
     */
    private String workerAddress;
    /**
     * 用户配置
     */
    private WorkerConfig workerConfig;
    /**
     * 通讯器
     */
    private Transporter transporter;
    /**
     * 处理器加载器
     */
    private ProcessorLoader processorLoader;

    private ExecutorManager executorManager;


    private ServerDiscoveryService serverDiscoveryService;

    private TaskPersistenceService taskPersistenceService;

    public Long getAppId() {
        return Optional.ofNullable(app.getAppId()).orElse(-1L);
    }
}
